package com.itzsj.exceptionHandle;

import com.itzsj.exception.BaseException;
import com.itzsj.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandle {

    @ExceptionHandler(BaseException.class)
    public Result baseException(BaseException exception) {
        log.error("BaseException: {}",exception.toString());
        return Result.error(exception.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public void AllException(Exception exception) {
        log.error("Exception: {}",exception.toString());

    }
}
